local qingya = fk.CreateSkill {
  name = "lingling__qingya",
  tags = { Skill.Compulsory },
}

Fk:loadTranslationTable{
  ["lingling__qingya"] = "倾轧",
  [":lingling__qingya"] = "锁定技，当一名其他角色死亡时，若你体力上限小于6，你加1点体力上限，然后摸两张牌；"..
  "当一名其他角色本轮首次进入濒死状态时，若你体力值大于1，你失去1点体力，然后摸两张牌。",
}

qingya:addEffect(fk.Death, {
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(qingya.name) and player.maxHp < 6
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:changeMaxHp(player, 1)
    if not player.dead then
      player:drawCards(2, qingya.name)
    end
  end,
})

qingya:addEffect(fk.EnterDying, {
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(qingya.name) and target ~= player and player.hp > 1 then
      local dying_events =  player.room.logic:getEventsOfScope(GameEvent.Dying, 1, function (e)
        return e.data.who == target
      end, Player.HistoryRound)
      return #dying_events == 1 and dying_events[1].data == data
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:loseHp(player, 1, qingya.name)
    if not player.dead then
      player:drawCards(2, qingya.name)
    end
  end,
})

return qingya
